﻿using System;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fcdbas.WinUI.Controls
{
    public class cRepositoryItemImageEdit : DevExpress.XtraEditors.Repository.RepositoryItemImageEdit
    {
        public cRepositoryItemImageEdit()
        {
            this.ParseEditValue += new DevExpress.XtraEditors.Controls.ConvertEditValueEventHandler(cRepositoryItemImageEdit_ParseEditValue);
            this.Modified += new EventHandler(cRepositoryItemImageEdit_Modified);
        }
        private bool _IsEditing;
        public bool IsEditing
        {
            get
            {
                return _IsEditing;
            }
            set
            {
                _IsEditing = value;
            }
        }
        void cRepositoryItemImageEdit_Modified(object sender, EventArgs e)
        {
            IsEditing = true;
        }

        void cRepositoryItemImageEdit_ParseEditValue(object sender, DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e)
        {
            if (e.Value != null)
            {
                if (e.Value is Image)
                {
                    Bitmap bm = e.Value as Bitmap;
                    e.Value = Fcdbas.Core.Util.BitmapHelper.BitmapToBytes(bm);
                    e.Handled = true;
                }
            }
        }
    }
}
